package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.loginentityservice;

@WebServlet("/login")
public class login extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;utf-8");
		loginentityservice log=new loginentityservice();
		String phone=req.getParameter("phone");
		String userPassword=req.getParameter("userPassword");
		int n=log.cha(phone, userPassword);
		if(n>0){
			resp.getWriter().print("<script>alert('登陆成功');location.href='/RadBooks/selectuser';</script>");
			
//			resp.getWriter().print(n);
		}else{
//			resp.getWriter().print(n);
			resp.getWriter().print("<script>alert('登陆失败');location.href='/RadBooks/selectuser';</script>");
		}
	}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
		}
}
